<!DOCTYPE html>
<htm>
    <head>
        <title>邮箱验证</title>
        <script>
            function fun(){
                var email = document.forms["form"]["fname"].value;
                var atpos=email.indexOf("@");
                var dotpos = email.lastIndexOf(".");
                if(atpos<1 || dotpos<atpos+2 || dotpos+2>email.length){
                    alert("请输入正确邮箱")
                    return false;
                }
            }
        </script>
    </head>
    <body>
        <p>请输入邮箱</p>
        <form name="form" onsubmit="return fun()" method="post">
            <input type="text" name="fname">
            <input type="submit" value="提交">
        </form>
    </body>
</htm>